{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Chapter 18",
      "provenance": [],
      "collapsed_sections": [],
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/jo-cho/advances_in_financial_machine_learning/blob/master/Chapter_18.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "vXbpaTecP2FS",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "3455cb08-2ca6-4ebb-bc4f-d7c09e3d275e"
      },
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "!pip install -q mlfinlab\n",
        "from mlfinlab import data_structures, features, filters, labeling, util"
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "\u001b[?25l\r\u001b[K     |██▊                             | 10kB 35.4MB/s eta 0:00:01\r\u001b[K     |█████▌                          | 20kB 1.7MB/s eta 0:00:01\r\u001b[K     |████████▎                       | 30kB 2.4MB/s eta 0:00:01\r\u001b[K     |███████████                     | 40kB 1.6MB/s eta 0:00:01\r\u001b[K     |█████████████▉                  | 51kB 1.8MB/s eta 0:00:01\r\u001b[K     |████████████████▋               | 61kB 2.2MB/s eta 0:00:01\r\u001b[K     |███████████████████▍            | 71kB 2.4MB/s eta 0:00:01\r\u001b[K     |██████████████████████▏         | 81kB 2.5MB/s eta 0:00:01\r\u001b[K     |█████████████████████████       | 92kB 2.8MB/s eta 0:00:01\r\u001b[K     |███████████████████████████▊    | 102kB 2.7MB/s eta 0:00:01\r\u001b[K     |██████████████████████████████▌ | 112kB 2.7MB/s eta 0:00:01\r\u001b[K     |████████████████████████████████| 122kB 2.7MB/s \n",
            "\u001b[?25h"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "osUXETHvW-YH",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import warnings\n",
        "warnings.filterwarnings(action='ignore')"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "BK5JToDuRObv",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 128
        },
        "outputId": "80ecc383-22b0-4b4a-9be4-35317238b446"
      },
      "source": [
        "from google.colab import drive\n",
        "drive.mount('/content/drive')"
      ],
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&response_type=code&scope=email%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdocs.test%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.photos.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fpeopleapi.readonly\n",
            "\n",
            "Enter your authorization code:\n",
            "··········\n",
            "Mounted at /content/drive\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "uHUFg2KJRc6d",
        "colab_type": "text"
      },
      "source": [
        "#1. Form dollar bars on E-mini S&P 500 futures:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8FBCD-Q_RFK1",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 90
        },
        "outputId": "a8f17ec2-4ca1-4eda-f082-31c66ec1c575"
      },
      "source": [
        "raw_dollar_bars = data_structures.get_dollar_bars('/content/drive/My Drive/Colab Notebooks/csv/clean_IVE_tickbidask2.csv', threshold=1000000)\n",
        "dollar_bars = raw_dollar_bars.set_index(pd.to_datetime(raw_dollar_bars.date_time))\n",
        "dollar_bars = dollar_bars.drop(columns='date_time')\n",
        "dollar_bars = dollar_bars.reset_index().drop_duplicates(subset='date_time', keep='last').set_index('date_time')"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Reading data in batches:\n",
            "Batch number: 0\n",
            "Returning bars \n",
            "\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "dy0PqE-dRYSV",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 228
        },
        "outputId": "98b00cd1-e94f-4587-f5f1-afa4369c60d0"
      },
      "source": [
        "dollar_bars.head()"
      ],
      "execution_count": 5,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>open</th>\n",
              "      <th>high</th>\n",
              "      <th>low</th>\n",
              "      <th>close</th>\n",
              "      <th>volume</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>date_time</th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>2009-09-28 09:46:35</th>\n",
              "      <td>50.79</td>\n",
              "      <td>51.07</td>\n",
              "      <td>50.710</td>\n",
              "      <td>51.07</td>\n",
              "      <td>19844</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 09:53:49</th>\n",
              "      <td>51.07</td>\n",
              "      <td>51.15</td>\n",
              "      <td>51.050</td>\n",
              "      <td>51.14</td>\n",
              "      <td>20324</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 09:55:26</th>\n",
              "      <td>51.14</td>\n",
              "      <td>51.15</td>\n",
              "      <td>51.129</td>\n",
              "      <td>51.14</td>\n",
              "      <td>19622</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:02:52</th>\n",
              "      <td>51.14</td>\n",
              "      <td>51.26</td>\n",
              "      <td>51.080</td>\n",
              "      <td>51.25</td>\n",
              "      <td>22319</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:10:21</th>\n",
              "      <td>51.25</td>\n",
              "      <td>51.29</td>\n",
              "      <td>51.190</td>\n",
              "      <td>51.29</td>\n",
              "      <td>21519</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "                      open   high     low  close  volume\n",
              "date_time                                               \n",
              "2009-09-28 09:46:35  50.79  51.07  50.710  51.07   19844\n",
              "2009-09-28 09:53:49  51.07  51.15  51.050  51.14   20324\n",
              "2009-09-28 09:55:26  51.14  51.15  51.129  51.14   19622\n",
              "2009-09-28 10:02:52  51.14  51.26  51.080  51.25   22319\n",
              "2009-09-28 10:10:21  51.25  51.29  51.190  51.29   21519"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 5
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wEeo45d2TMcu",
        "colab_type": "text"
      },
      "source": [
        "## (a) Quantize the returns series using the binary method."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "EpMRImvTVjr1",
        "colab_type": "text"
      },
      "source": [
        "a stream of\n",
        "returns rt can be encoded according to the sign, 1 for rt > 0, 0 for rt < 0, removing\n",
        "cases where rt = 0."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "j-8yUk5uTkM6",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "df = dollar_bars[['close']]"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "5DPq2YyAU0AL",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 126
        },
        "outputId": "e5d6b151-77af-4d76-a323-58b5badb6bab"
      },
      "source": [
        "df['ret'] = np.log(df.close).diff()\n",
        "df=df.dropna()"
      ],
      "execution_count": 7,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:1: SettingWithCopyWarning: \n",
            "A value is trying to be set on a copy of a slice from a DataFrame.\n",
            "Try using .loc[row_indexer,col_indexer] = value instead\n",
            "\n",
            "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
            "  \"\"\"Entry point for launching an IPython kernel.\n"
          ],
          "name": "stderr"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "1nkAd2paTFEv",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "df['bin_encod']=np.nan\n",
        "\n",
        "df.loc[df.ret>0,'bin_encod']=1\n",
        "df.loc[df.ret<0,'bin_encod']=0\n",
        "\n",
        "df2=df.dropna()"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Msww-W3JTuvI",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 228
        },
        "outputId": "032fe3c8-631d-4aa6-a171-89a0cd603bc2"
      },
      "source": [
        "df2.head()"
      ],
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>close</th>\n",
              "      <th>ret</th>\n",
              "      <th>bin_encod</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>date_time</th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>2009-09-28 09:53:49</th>\n",
              "      <td>51.14</td>\n",
              "      <td>0.001370</td>\n",
              "      <td>1.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:02:52</th>\n",
              "      <td>51.25</td>\n",
              "      <td>0.002149</td>\n",
              "      <td>1.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:10:21</th>\n",
              "      <td>51.29</td>\n",
              "      <td>0.000780</td>\n",
              "      <td>1.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:19:36</th>\n",
              "      <td>51.23</td>\n",
              "      <td>-0.001171</td>\n",
              "      <td>0.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:24:23</th>\n",
              "      <td>51.25</td>\n",
              "      <td>0.000390</td>\n",
              "      <td>1.0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "                     close       ret  bin_encod\n",
              "date_time                                      \n",
              "2009-09-28 09:53:49  51.14  0.001370        1.0\n",
              "2009-09-28 10:02:52  51.25  0.002149        1.0\n",
              "2009-09-28 10:10:21  51.29  0.000780        1.0\n",
              "2009-09-28 10:19:36  51.23 -0.001171        0.0\n",
              "2009-09-28 10:24:23  51.25  0.000390        1.0"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 9
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "j7NJ3ui3XUcB",
        "colab_type": "text"
      },
      "source": [
        "##(b) Quantize the returns series using the quantile encoding, using 10 letters."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "92mTJJyvUvg6",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 228
        },
        "outputId": "5d6e74c8-2ff2-4ced-bebc-4855c2dd8d3b"
      },
      "source": [
        "df['quant_encod']=pd.qcut(df.ret, q=10, labels=range(1,11))\n",
        "df.head()"
      ],
      "execution_count": 10,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>close</th>\n",
              "      <th>ret</th>\n",
              "      <th>bin_encod</th>\n",
              "      <th>quant_encod</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>date_time</th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>2009-09-28 09:53:49</th>\n",
              "      <td>51.14</td>\n",
              "      <td>0.001370</td>\n",
              "      <td>1.0</td>\n",
              "      <td>9</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 09:55:26</th>\n",
              "      <td>51.14</td>\n",
              "      <td>0.000000</td>\n",
              "      <td>NaN</td>\n",
              "      <td>5</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:02:52</th>\n",
              "      <td>51.25</td>\n",
              "      <td>0.002149</td>\n",
              "      <td>1.0</td>\n",
              "      <td>10</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:10:21</th>\n",
              "      <td>51.29</td>\n",
              "      <td>0.000780</td>\n",
              "      <td>1.0</td>\n",
              "      <td>8</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:19:36</th>\n",
              "      <td>51.23</td>\n",
              "      <td>-0.001171</td>\n",
              "      <td>0.0</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "                     close       ret  bin_encod quant_encod\n",
              "date_time                                                  \n",
              "2009-09-28 09:53:49  51.14  0.001370        1.0           9\n",
              "2009-09-28 09:55:26  51.14  0.000000        NaN           5\n",
              "2009-09-28 10:02:52  51.25  0.002149        1.0          10\n",
              "2009-09-28 10:10:21  51.29  0.000780        1.0           8\n",
              "2009-09-28 10:19:36  51.23 -0.001171        0.0           2"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 10
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "lqB2cwP9XD9B",
        "colab_type": "text"
      },
      "source": [
        "## (c) Quantize the returns series using the sigma encoding, where 𝜎 is the standard deviation of all bar returns."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "m4QPjQ8eg8pm",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 437
        },
        "outputId": "4f0be41e-49a1-4b5d-b78e-8cc01a199b18"
      },
      "source": [
        "x = df.ret.min()\n",
        "base = [x]\n",
        "while df.ret.max() > x:\n",
        "    x += df.ret.std()\n",
        "    base.append(x)\n",
        "\n",
        "df['sigma_encod'] = np.digitize(df.ret, base)\n",
        "df"
      ],
      "execution_count": 11,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>close</th>\n",
              "      <th>ret</th>\n",
              "      <th>bin_encod</th>\n",
              "      <th>quant_encod</th>\n",
              "      <th>sigma_encod</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>date_time</th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>2009-09-28 09:53:49</th>\n",
              "      <td>51.14</td>\n",
              "      <td>0.001370</td>\n",
              "      <td>1.0</td>\n",
              "      <td>9</td>\n",
              "      <td>120</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 09:55:26</th>\n",
              "      <td>51.14</td>\n",
              "      <td>0.000000</td>\n",
              "      <td>NaN</td>\n",
              "      <td>5</td>\n",
              "      <td>120</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:02:52</th>\n",
              "      <td>51.25</td>\n",
              "      <td>0.002149</td>\n",
              "      <td>1.0</td>\n",
              "      <td>10</td>\n",
              "      <td>120</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:10:21</th>\n",
              "      <td>51.29</td>\n",
              "      <td>0.000780</td>\n",
              "      <td>1.0</td>\n",
              "      <td>8</td>\n",
              "      <td>120</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:19:36</th>\n",
              "      <td>51.23</td>\n",
              "      <td>-0.001171</td>\n",
              "      <td>0.0</td>\n",
              "      <td>2</td>\n",
              "      <td>119</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2019-06-28 15:58:59</th>\n",
              "      <td>116.56</td>\n",
              "      <td>-0.000858</td>\n",
              "      <td>0.0</td>\n",
              "      <td>2</td>\n",
              "      <td>119</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2019-06-28 15:59:02</th>\n",
              "      <td>116.57</td>\n",
              "      <td>0.000086</td>\n",
              "      <td>1.0</td>\n",
              "      <td>6</td>\n",
              "      <td>120</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2019-06-28 15:59:45</th>\n",
              "      <td>116.56</td>\n",
              "      <td>-0.000086</td>\n",
              "      <td>0.0</td>\n",
              "      <td>5</td>\n",
              "      <td>120</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2019-06-28 16:00:00</th>\n",
              "      <td>116.57</td>\n",
              "      <td>0.000086</td>\n",
              "      <td>1.0</td>\n",
              "      <td>6</td>\n",
              "      <td>120</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2019-06-28 17:29:22</th>\n",
              "      <td>116.57</td>\n",
              "      <td>0.000000</td>\n",
              "      <td>NaN</td>\n",
              "      <td>5</td>\n",
              "      <td>120</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>58606 rows × 5 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "                      close       ret  bin_encod quant_encod  sigma_encod\n",
              "date_time                                                                \n",
              "2009-09-28 09:53:49   51.14  0.001370        1.0           9          120\n",
              "2009-09-28 09:55:26   51.14  0.000000        NaN           5          120\n",
              "2009-09-28 10:02:52   51.25  0.002149        1.0          10          120\n",
              "2009-09-28 10:10:21   51.29  0.000780        1.0           8          120\n",
              "2009-09-28 10:19:36   51.23 -0.001171        0.0           2          119\n",
              "...                     ...       ...        ...         ...          ...\n",
              "2019-06-28 15:58:59  116.56 -0.000858        0.0           2          119\n",
              "2019-06-28 15:59:02  116.57  0.000086        1.0           6          120\n",
              "2019-06-28 15:59:45  116.56 -0.000086        0.0           5          120\n",
              "2019-06-28 16:00:00  116.57  0.000086        1.0           6          120\n",
              "2019-06-28 17:29:22  116.57  0.000000        NaN           5          120\n",
              "\n",
              "[58606 rows x 5 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 11
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Qlvb_xuOkYeP",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 690
        },
        "outputId": "e794bfda-3f77-42d4-8cd5-61596613404f"
      },
      "source": [
        "df.sigma_encod.value_counts()"
      ],
      "execution_count": 12,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "120    37666\n",
              "119    15734\n",
              "121     2777\n",
              "118     1224\n",
              "122      444\n",
              "117      275\n",
              "123      137\n",
              "116      110\n",
              "124       72\n",
              "115       42\n",
              "125       32\n",
              "114       18\n",
              "113       14\n",
              "126       13\n",
              "111        5\n",
              "128        5\n",
              "112        5\n",
              "127        5\n",
              "129        4\n",
              "110        3\n",
              "109        3\n",
              "108        3\n",
              "106        2\n",
              "222        1\n",
              "99         1\n",
              "151        1\n",
              "1          1\n",
              "97         1\n",
              "130        1\n",
              "102        1\n",
              "131        1\n",
              "145        1\n",
              "135        1\n",
              "107        1\n",
              "149        1\n",
              "96         1\n",
              "Name: sigma_encod, dtype: int64"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 12
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "aL5puTNwctDz",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "52075ffd-f549-4e5e-c499-4adb490ff591"
      },
      "source": [
        "import math\n",
        "math.ceil(( df.ret.max()-df.ret.min() )/ df.ret.std())"
      ],
      "execution_count": 13,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "222"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 13
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "m3im6sUYkWQC",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "fac0f8d1-9b11-47b2-ad73-f644c689af26"
      },
      "source": [
        "df.sigma_encod.max()"
      ],
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "222"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 14
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0Ir-YEWPiIZp",
        "colab_type": "text"
      },
      "source": [
        "## (d) Compute the entropy of the three encoded series, using the plug-in method."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "yafYPXHTkgb6",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "def plugIn(msg,w):\n",
        "    pmf=pmf1(msg,w)\n",
        "    out=-sum([pmf[i]*np.log2(pmf[i]) for i in pmf])/w \n",
        "    return out,pmf\n",
        "\n",
        "def pmf1(msg,w):\n",
        "    lib={} \n",
        "    if not isinstance(msg,str): msg=''.join(map(str,msg)) \n",
        "    for i in range(w,len(msg)): \n",
        "        msg_=msg[i-w:i] \n",
        "        if msg_ not in lib:lib[msg_]=[i-w] \n",
        "        else:lib[msg_]=lib[msg_]+[i-w] \n",
        "    pmf=ﬂoat(len(msg)-w) \n",
        "    pmf={i:len(lib[i])/pmf for i in lib} \n",
        "    return pmf"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "7y80YYfhk_XR",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "d18f43ca-0d4f-48d8-e129-f922ae2fcc8e"
      },
      "source": [
        "plugIn(df.bin_encod, w=100)[0]"
      ],
      "execution_count": 16,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "0.17422902458497488"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 16
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "PG6GQ3kLlnGS",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "5bf5eee8-cb35-4bb2-c060-43e002e9cfaf"
      },
      "source": [
        "plugIn(df.quant_encod,w=100)[0]"
      ],
      "execution_count": 17,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "0.15974033609198546"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 17
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "3fMm7VLdltxK",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "2befcde9-aa17-4495-ac28-294c65f8d335"
      },
      "source": [
        "plugIn(df.sigma_encod, w=100)[0]"
      ],
      "execution_count": 18,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "0.173731080960602"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 18
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qhI0aRHBl8fa",
        "colab_type": "text"
      },
      "source": [
        "## (e) Compute the entropy of the three encoded series, using Kontoyiannis’ method, with a window size of 100."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "tz_VTVbRmCSY",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "def matchLength(msg,i,n):\n",
        "    # Maximum matched length+1, with overlap.\n",
        "    # i>=n & len(msg)>=i+n\n",
        "    subS=''\n",
        "    for l in range(n):\n",
        "        msg1=msg[i:i+l+1]\n",
        "        for j in range(i-n,i):\n",
        "            msg0=msg[j:j+l+1]\n",
        "            if msg1==msg0:\n",
        "                subS=msg1\n",
        "                break # search for higher l.\n",
        "    return len(subS)+1,subS # matched length + 1\n",
        "\n",
        "def konto(msg,window=None):\n",
        "    \"\"\"\n",
        "    * Kontoyiannis’ LZ entropy estimate, 2013 version (centered window).\n",
        "    * Inverse of the avg length of the shortest non-redundant substring.\n",
        "    * If non-redundant substrings are short, the text is highly entropic.\n",
        "    * window==None for expanding window, in which case len(msg)%2==0\n",
        "    * If the end of msg is more relevant, try konto(msg[::-1])\n",
        "    \"\"\"\n",
        "    out={'num':0,'sum':0,'subS':[]}\n",
        "    if not isinstance(msg,str):\n",
        "        msg = ''.join(map(str,msg))\n",
        "        if window is None:\n",
        "            points = range(1,len(msg)/2+1)\n",
        "        else:\n",
        "            window = min(window,len(msg)/2)\n",
        "            points = range(window,len(msg)-window+1)\n",
        "        for i in points:\n",
        "            if window is None:\n",
        "                l,msg_ = matchLength(msg,i,i)\n",
        "                out['sum'] += np.log2(i+1)/l # to avoid Doeblin condition\n",
        "            else:\n",
        "                l,msg_ = matchLength(msg,i,window)\n",
        "                out['sum'] += np.log2(window+1)/l # to avoid Doeblin condition\n",
        "            out['subS'].append(msg_)\n",
        "            out['num'] += 1\n",
        "        out['h']=out['sum']/out['num']\n",
        "        out['r']=1-out['h']/np.log2(len(msg)) # redundancy, 0<=r<=1\n",
        "        return out"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "4bHtGhOVmwii",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "9d902cf5-e20a-4b53-d910-98ddbd77193b"
      },
      "source": [
        "konto(df.bin_encod,window=100)['h']"
      ],
      "execution_count": 20,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "0.5383269676743115"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 20
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "mn8IAzd6m7cs",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "421a9c99-ca59-4cec-b5fb-462fda58fe3e"
      },
      "source": [
        "konto(df.quant_encod,window=100)['h']"
      ],
      "execution_count": 21,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "2.3644591659386207"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 21
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "mlq3BYfPnACz",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "bd38e2ec-6fc3-4359-a0df-75bd74a4e6d6"
      },
      "source": [
        "konto(df.sigma_encod,window=100)['h']"
      ],
      "execution_count": 22,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "0.6252739495152874"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 22
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wdkxDq53Sv50",
        "colab_type": "text"
      },
      "source": [
        "해설:"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "HchvH__WnZya",
        "colab_type": "text"
      },
      "source": [
        "# 2. Using the bars from exercise 1:"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "vUFC-npm_mqV",
        "colab_type": "text"
      },
      "source": [
        "## (a) Compute the returns series, {rt}."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "J2zksj6P_sWY",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "ret = df[['ret']]"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "cDo5Px2D_uLv",
        "colab_type": "text"
      },
      "source": [
        "##(b) Encode the series as follows: 0 if rtrt−1 < 0, and 1 if rtrt−1 ≥ 0."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "1C0dN4h2Vejt",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "ret['tmp']=ret.ret*ret.ret.shift(-1)\n",
        "ret.dropna(inplace=True)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "TAqouXbrDok1",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 228
        },
        "outputId": "b8205fee-3e38-4f85-f317-0a3921835552"
      },
      "source": [
        "ret['encode'] = 1\n",
        "ret.loc[ret.tmp < 0, 'encode'] =0\n",
        "ret.drop(['tmp'],axis=1,inplace=True)\n",
        "ret.head()"
      ],
      "execution_count": 133,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>ret</th>\n",
              "      <th>encode</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>date_time</th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>2009-09-28 09:53:49</th>\n",
              "      <td>0.001370</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 09:55:26</th>\n",
              "      <td>0.000000</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:02:52</th>\n",
              "      <td>0.002149</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:10:21</th>\n",
              "      <td>0.000780</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2009-09-28 10:19:36</th>\n",
              "      <td>-0.001171</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "                          ret  encode\n",
              "date_time                            \n",
              "2009-09-28 09:53:49  0.001370       1\n",
              "2009-09-28 09:55:26  0.000000       1\n",
              "2009-09-28 10:02:52  0.002149       1\n",
              "2009-09-28 10:10:21  0.000780       0\n",
              "2009-09-28 10:19:36 -0.001171       0"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 133
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "tWqOJB-bDpg9",
        "colab_type": "text"
      },
      "source": [
        "## (c) Partition the series into 1000 non-overlapping subsets of equal size (you may have to drop some observations at the beginning).\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "uE6u7cw5PEJB",
        "colab_type": "text"
      },
      "source": [
        "not enough data, so i got 100 subsets instead"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "tT24xmb2D4oN",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "cce5b72b-349b-4faa-fd1e-148cace925f0"
      },
      "source": [
        "len(ret)/100"
      ],
      "execution_count": 134,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "586.05"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 134
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "k-JgRinAEEOv",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "00e0d925-fd11-4d1f-ab8b-11ac1378f7ca"
      },
      "source": [
        "ret_=ret.iloc[5:]\n",
        "len(ret_)"
      ],
      "execution_count": 135,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "58600"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 135
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JS_HYJ8gL-gY",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "chunks = [ret_[x:x+586] for x in range(0, len(ret_), 586)]"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "VPiHSPZKMEur",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 254
        },
        "outputId": "0e51e48a-a46f-4e6b-820a-5f616cb7358a"
      },
      "source": [
        "chunks[0].encode"
      ],
      "execution_count": 137,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "date_time\n",
              "2009-09-28 10:24:23    1\n",
              "2009-09-28 10:34:30    0\n",
              "2009-09-28 10:45:25    0\n",
              "2009-09-28 11:10:57    0\n",
              "2009-09-28 11:24:29    0\n",
              "                      ..\n",
              "2009-11-24 13:08:34    0\n",
              "2009-11-24 13:34:28    1\n",
              "2009-11-24 14:00:56    0\n",
              "2009-11-24 14:33:14    1\n",
              "2009-11-24 14:41:43    1\n",
              "Name: encode, Length: 586, dtype: int64"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 137
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "cMLvCeU8Pp5d",
        "colab_type": "text"
      },
      "source": [
        "##(d) Compute the entropy of each of the 1000 encoded subsets, using the plugin method.\n",
        "##(e) Compute the entropy of each of the 1000 encoded subsets, using the Kontoyiannis method, with a window size of 100."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "LkRg8tZFFqVN",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "ent_plug=[]\n",
        "for i in range(0,100):\n",
        "  ent_plug.append(plugIn(chunks[i].encode,w=100)[0])\n",
        "\n",
        "ent_kon=[]\n",
        "for i in range(0,100):\n",
        "  ent_kon.append(konto(chunks[i].encode,window=100)['h'])"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ZD3OaeIePi86",
        "colab_type": "text"
      },
      "source": [
        "## (f) Compute the correlation between results 2.d and 2.e."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "hAsAZiVzOIZV",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 198
        },
        "outputId": "2b0ad0f6-6ca1-46d1-f720-5f22ea8bb9ff"
      },
      "source": [
        "resultf = pd.DataFrame({'plugin':ent_plug,'konto':ent_kon})\n",
        "resultf.head()"
      ],
      "execution_count": 142,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>plugin</th>\n",
              "      <th>konto</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>0.089248</td>\n",
              "      <td>0.886276</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>0.089248</td>\n",
              "      <td>0.863965</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>0.089248</td>\n",
              "      <td>0.898317</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>0.089248</td>\n",
              "      <td>0.883224</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>0.089248</td>\n",
              "      <td>0.874946</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "     plugin     konto\n",
              "0  0.089248  0.886276\n",
              "1  0.089248  0.863965\n",
              "2  0.089248  0.898317\n",
              "3  0.089248  0.883224\n",
              "4  0.089248  0.874946"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 142
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "EAAMwYdyP-lG",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 108
        },
        "outputId": "e4513360-6309-4aa5-c0a4-af254f96aefd"
      },
      "source": [
        "resultf.corr()"
      ],
      "execution_count": 141,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>plugin</th>\n",
              "      <th>konto</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>plugin</th>\n",
              "      <td>1.000000e+00</td>\n",
              "      <td>1.365105e-15</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>konto</th>\n",
              "      <td>1.365105e-15</td>\n",
              "      <td>1.000000e+00</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "              plugin         konto\n",
              "plugin  1.000000e+00  1.365105e-15\n",
              "konto   1.365105e-15  1.000000e+00"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 141
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "h9SiWttnSr0G",
        "colab_type": "text"
      },
      "source": [
        "해설:"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "sh88doSIP_ts",
        "colab_type": "text"
      },
      "source": [
        "# 3. Draw 1000 observations from a standard Normal distribution:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "nWHpbHFLQkCg",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "snd = np.random.normal(0,1,1000)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "blcmBZ4wQrrf",
        "colab_type": "text"
      },
      "source": [
        "## (a) What is the true entropy of this process?"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Ny71ZAkFQ3BO",
        "colab_type": "text"
      },
      "source": [
        "$H = {1\\over2}log|2\\pi e \\sigma^2|_{\\sigma^2=1} \\approx 1.42$"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "hI_Zx0rjQuLa",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "fbd80a69-45e8-4985-c3de-6448652da982"
      },
      "source": [
        "h = 1/2*np.log(abs(2*np.pi*np.e*snd.std()))\n",
        "h.round(2)"
      ],
      "execution_count": 103,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "1.42"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 103
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "rjAQUkIDRFuP",
        "colab_type": "text"
      },
      "source": [
        "##(b) Label the observations according to 8 quantiles.\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "MRNEy8TXQ_3y",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 72
        },
        "outputId": "d9af3b44-8f3f-4a94-b1cc-7876a32b7ed7"
      },
      "source": [
        "quant = pd.qcut(snd, q=8, labels = range(1,9))\n",
        "quant"
      ],
      "execution_count": 104,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[5, 4, 6, 5, 8, ..., 2, 4, 2, 2, 5]\n",
              "Length: 1000\n",
              "Categories (8, int64): [1 < 2 < 3 < 4 < 5 < 6 < 7 < 8]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 104
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "5IQCNX6mR4pp",
        "colab_type": "text"
      },
      "source": [
        "##(c) Estimate the entropy using the plug-in method.\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "O_gEnBXoRtdN",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "d038925c-e56e-481c-ce7d-52edf8f046db"
      },
      "source": [
        "plugIn(quant,w=100)[0]"
      ],
      "execution_count": 105,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "0.0981378119121713"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 105
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "hktRcQ01R_vO",
        "colab_type": "text"
      },
      "source": [
        "##(d) Estimate the entropy using the Kontoyiannis method:\n",
        "(i) using a window size of 10.\n",
        "(ii) using a window size of 100."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "U5qplr7oR9a6",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "bd0af468-0495-4216-84f1-743bbb2a50da"
      },
      "source": [
        "#(i)\n",
        "konto(quant,window=10)['h']"
      ],
      "execution_count": 106,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "2.1095127362577264"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 106
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "tCg11y1wSJtw",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "ab4cc0eb-aa05-4a69-eebe-0589587bad79"
      },
      "source": [
        "#(ii)\n",
        "konto(quant,window=100)['h']"
      ],
      "execution_count": 107,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "2.3352229037299943"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 107
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "u6ex7pKjSmEV",
        "colab_type": "text"
      },
      "source": [
        "해설: "
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "xIg71ay3Shju",
        "colab_type": "text"
      },
      "source": [
        "# 4. Using the draws from exercise 3, {xt}t=1,…,1000:"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "7Ng1YF1wSN_P",
        "colab_type": "text"
      },
      "source": [
        "##(a) Compute yt = 𝜌yt−1 + xt, where 𝜌 = .5, y0 = 0."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "H4phBwMyS1fC",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "2a303958-6ab5-4ee3-d959-ceb862006044"
      },
      "source": [
        "len(x)"
      ],
      "execution_count": 151,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "1000"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 151
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ohK6B5CgYw9j",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "70804193-9077-4830-8977-37f31fda598c"
      },
      "source": [
        "y = [0]\n",
        "for i in range(len(snd)) : y.append(0.5*y[-1]+snd[i])\n",
        "len(y)"
      ],
      "execution_count": 150,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "1001"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 150
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "-rgfkmmYS278",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "y=y[0:1000]"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "cIZlAerZZJw8",
        "colab_type": "text"
      },
      "source": [
        "## (b) Label {y_t} the observations according to 8 quantiles."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Dd3L0e4FYyR8",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "quanty = pd.qcut(y,q=8,labels=range(1,9))"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "_yfHE94DZqc2",
        "colab_type": "text"
      },
      "source": [
        "##(c) Estimate the entropy using the plug-in method.\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "m7qpkM3uZREs",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "08d22966-9b6e-497d-da82-34172d42c657"
      },
      "source": [
        "plugIn(quanty,w=100)[0]"
      ],
      "execution_count": 156,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "0.0981378119121713"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 156
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4KfhreyeZt9v",
        "colab_type": "text"
      },
      "source": [
        "##(d) Estimate the entropy using the Kontoyiannis method\n",
        "(i) using a window size of 10.\n",
        "(ii) using a window size of 100."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "M2f8e-U2ZxEx",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "c6351655-0747-4932-a4f3-b624f1872468"
      },
      "source": [
        "#(i)\n",
        "konto(quanty,window=10)['h']"
      ],
      "execution_count": 157,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "2.079042668435694"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 157
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "y_hxUkPOZ1iE",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "8468da9d-abe2-4f75-b4ac-3796b7286e3f"
      },
      "source": [
        "#(ii)\n",
        "konto(quanty,window=100)['h']"
      ],
      "execution_count": 158,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "2.2885548617695646"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 158
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "eGH8TVMuZ7Ti",
        "colab_type": "text"
      },
      "source": [
        "해설:"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "S5jeqgDHZ4tT",
        "colab_type": "text"
      },
      "source": [
        "# 5. Suppose a portfolio of 10 holdings with equal dollar allocations."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "31S--KEVaDTf",
        "colab_type": "text"
      },
      "source": [
        "#(a) \n",
        "The portion of the total risk contributed by the ith principal component is\n",
        "1/10\n",
        ", i = 1,…, 10. What is the portfolio’s entropy?"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "zLGQ-kBBakNf",
        "colab_type": "text"
      },
      "source": [
        "**From Meucci(2009), Portfolio Concentration**\n",
        "\n",
        "$$ H = 1-{1\\over N}exp\\left\\{\\sum_{i=1}^N\\theta_i log(\\theta_i)\\right\\} $$"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Mf44XRyqaj8h",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "def H(N,risk):\n",
        "  ret = 1-(1/N)*np.exp(np.sum(risk*np.log(risk)))\n",
        "  return ret"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "j6TBuJDmaJ5M",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "risk_a = np.ones(10)*1/10"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "U8CnOcQPb5UB",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "53ba42e8-0a21-4e1a-ef77-0ca50edb6e4e"
      },
      "source": [
        "H(10,risk_a)"
      ],
      "execution_count": 165,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "0.99"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 165
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "yShnmw-8cAOV",
        "colab_type": "text"
      },
      "source": [
        "## (b) \n",
        "The portion of the total risk contributed by the ith principal component is\n",
        "1 − i/55\n",
        ", i = 1,…, 10. What is the portfolio’s entropy?"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "02GfpmSRcKg7",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 199
        },
        "outputId": "d39b4f00-f7b1-4d2f-a23d-89c77ca38917"
      },
      "source": [
        "risk_b= []\n",
        "for i in range(1,11): risk_b.append(1-i/55)\n",
        "risk_b"
      ],
      "execution_count": 173,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[0.9818181818181818,\n",
              " 0.9636363636363636,\n",
              " 0.9454545454545454,\n",
              " 0.9272727272727272,\n",
              " 0.9090909090909091,\n",
              " 0.8909090909090909,\n",
              " 0.8727272727272728,\n",
              " 0.8545454545454545,\n",
              " 0.8363636363636364,\n",
              " 0.8181818181818181]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 173
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "anO77vTNcaEP",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "0da258aa-9915-42e5-917e-940c5b8a6315"
      },
      "source": [
        "H(10,risk_b)"
      ],
      "execution_count": 174,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "0.9606658852848915"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 174
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "3upbNRxDdyXn",
        "colab_type": "text"
      },
      "source": [
        "## (c) \n",
        "The portion of the total risk contributed by the ith principal component\n",
        "is 𝛼\n",
        "1\n",
        "10 + (1 − 𝛼)(1 − i\n",
        "55\n",
        "), i = 1,…, 10, 𝛼 ∈ [0, 1]. Plot the portolio’s\n",
        "entropy as a function of 𝛼."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "DH8CPAD2g31b",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "0FVw_xHgd32C",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "def entropy(alpha):\n",
        "  risk_c=[]\n",
        "  for i in range(1,11):risk_c.append( alpha/10 + (1-alpha)*(1-i/55) )\n",
        "  return H(10,risk_c)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "EuOuKCyLe5ML",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "alpha = np.linspace(0,1,1000)\n",
        "h = [entropy(a) for a in alpha]"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "7IMgZ3-rfeyH",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 285
        },
        "outputId": "107c35c2-a766-4ac9-e563-f3b86b957e1e"
      },
      "source": [
        "import matplotlib.pyplot as plt\n",
        "import seaborn as sns; sns.set()\n",
        "plt.plot(alpha,h)\n",
        "plt.ylabel('entropy')\n",
        "plt.xlabel('alpha')\n",
        "plt.show()"
      ],
      "execution_count": 206,
      "outputs": [
        {
          "output_type": "display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nNnz4cN566y0+//xznnzySX7xi19QV1d3xbb79+9nx44dvPvuu3zwwQfs2LHDfqygoIBRo0Zx9OhR\nHn30UX71q1/Zl76PiIjg1Vdf5YsvvuC3v/0tv/3tbzl16pRb8hPiSqS4COFi8+fPJyoqCrVazYIF\nCxg5cuQPriq8fPlywsLCMBgM/Ou//qt9gUXoXjjzvvvuQ6PRcO+991JfX2/fbviuu+5ixIgRqFQq\nkpKSmDZtGsePH3dLfkJciY+nAxBioHvvvffYvHkzVVVVALS1tdHY2HjFPWG+u/T7sGHDevRwhgwZ\nYv/3pR1A29raAPjoo4945ZVXKCsrw2az0dHRwU033eSSfIRwhPRchHChqqoqnnvuOX79619z7Ngx\njh8/ftWl27+7I2J1dTWRkZG9vobZbGbVqlUsW7aMw4cPc/z4ce64445+u1ukGBikuAjhQu3t7ahU\nKvt+ITt27ODMmTM/2P7111/nwoULGI1Gtm3bxoIFC3p9DbPZjNlsRqvV4uPjw0cffcThw4edloMQ\n10OGxYRwodjYWJYtW8YDDzyASqUiIyODyZMn/2D72bNns2jRIlpaWrj33ntZvHhxr68RFBTEc889\nx89+9jPMZjMzZ85k1qxZzkxDiGsm+7kI0UeMGzeOffv2MXLkSE+HIsQNk2ExIYQQTifFRQghhNPJ\nsJgQQgink56LEEIIp5PiIoQQwumkuAghhHA6KS5CCCGcToqLEEIIp5PiIoQQwun+f8hBTCqmcjmw\nAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "E-xqF22ygW9p",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": 0,
      "outputs": []
    }
  ]
}